﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DXApplication2
{
    class clsNgay
    {
        DateTime day;
        public string maphong;
        int succhua;
        int loaiphong;
        List<string> cathi;
        public clsNgay()
        {
            day = new DateTime();
            maphong = "";
            succhua = 0;
            loaiphong=0;
            cathi = new List<string>(4);
        }
        public clsNgay(DateTime a,string mp,int sc,int lp)
        {
            day = a;
            maphong = mp;
            succhua = sc;
            loaiphong = lp;
            cathi = new List<string>();
            cathi.Add("90");
            cathi.Add("120");
            cathi.Add("90");
            cathi.Add("120");
        }
        public string getcathi(int i)
        {
            return cathi[i];
        }
        public int getsucchua()
        {
            return succhua;
        }
        public int getthoigiancathi(int i)
        {
            return int.Parse(cathi[i]);
        }
        public void setcathi(int i)
        {
            cathi[i] = "0";
        }
        public string getmaphong()
        {
            return maphong;
        }
        public string timcathi(int thoigian)
        {
            if (thoigian <= 90)
            {
                if (this.cathi[0] != "0")
                    return "0";
                else
                {
                    if (this.cathi[2] != "0")
                        return "2";
                    else
                        return null;
                }

            }
            else
            {
                if (this.cathi[1] != "0")
                    return "1";
                else
                {
                    if (this.cathi[3] != "0")
                        return "3";
                    else
                        return null;
                }
            }

        }
        public bool checkcathi(int i)
        {
                if (cathi[i] != "0")
                    return true;
            return false;
        }
        public bool checkloaiphong(int loai)
        {
            if (loai == loaiphong)
                return true;
            return false;
        }
        public bool kiemtrasucchua(int siso)
        {
            if (siso <= ((this.succhua / 2) + 5) && siso >= ((this.succhua / 2)-5))
                return true;
            return false;
        }
        public DateTime getngay()
        {
            return day;
        }
        public void add(clsNgay a)
        {
            this.day = a.day;
            this.succhua = a.succhua;
            this.maphong = a.maphong;
            this.cathi = a.cathi;
        }
        public bool nhohon(clsNgay a)
        {
            if (a.succhua > this.succhua)
                return true;
            return false;
        }
        public bool checkphong()
        {
            if (cathi[0] == "0" && cathi[1] == "0" && cathi[2] == "0" && cathi[3] == "0")
                return true;
            return false;
        }
        bool kiemtraphong(int siso, int thoigianthi)
        {
            string[] ketqua = new string[3];
            if (this.timcathi(thoigianthi) != null && this.kiemtrasucchua(siso))
                return true;
            return false;
        }
        public bool kiemtrat7()
        {
            if (day.DayOfWeek.ToString() == "Sunday" || day.DayOfWeek.ToString() == "Saturday")
                return true;
            return false;
        }
    }
}
